<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends CommonController {
    public function index(){
        $this->show();
    }


    // 核对登陆信息
    public function checkdata(){
         if (!$res=M('user')->where(array('email'=>I('post.username'),'password'=>md5(I('post.password'))))->find()) {
           
         	$arr=array(
                'error'=>'1',
                'info'=>'账号或密码错误'
         		);
         	echo json_encode($arr);
         	exit;
         }elseif($res['is_admin']!=1){
            $arr=array(
                'error'=>'2',
                'info'=>'你没权限登陆'
         		);
         	echo json_encode($arr);
         	exit;
         }else{
             $_SESSION['id']=$res['id'];
              $arr=array(
                'error'=>'3',
                'info'=>'登陆成功'
         		);
         	echo json_encode($arr);
         	exit;


         }
    }

     // 退出
   public function logout(){
        session_unset();
        session_destroy();
        $this->success('退出成功',U('admin/login/index'));


    
   }
}